program trab02;


uses
        crt;


type
        funcionario = record
                nome: string;
                sb  : real;
                inss: real;
                irpf: real;
                sl  : real;
        end;

const
        N = 2;

var
        f: array [1..N] of funcionario;
        i, j: integer;
        op: char;
        t, s: real;

        procedure coletardados;
        begin
                for i := 1 to N do
                begin
                        clrscr;
                        writeln('Coleta de Dados: Funcionario (', i, ')');


                        write('   Nome.......: ');
                        readln(f[i].nome);
                        write('   S. Bruto...: ');
                        readln(f[i].sb);

                        if (f[i].sb <= 1100) then
                        begin
                                f[i].inss := f[i].sb * 0.08;
                                f[i].irpf := 0.0;
                        end
                        else
                        if ((f[i].sb > 1100) and (f[i].sb < 2700)) then
                        begin
                                f[i].inss := f[i].sb * 0.08;
                                f[i].irpf := f[i].sb * 0.15;
                        end
                        else
                        begin
                                f[i].inss := f[i].sb * 0.11;
                                f[i].irpf := f[i].sb * 0.275;
                        end;
                        writeln('   INSS.....: ', f[i].inss:2:2);
                        writeln('   IRPF.....: ', f[i].irpf:2:2);
                        s := f[i].sb - (f[i].inss + f[i].irpf);
                        writeln('   S.Liquido: ', s:2:2);
                        readkey;
                end;

        end;

        procedure relatorio;
        begin

                clrscr;
                writeln('Relatorio Geral:');

                for i := 1 to n do
                begin
                        writeln('  Nome.....: ', f[i].nome );
                        writeln('  S.Bruto..: ', f[i].sb:2:2   );
                        writeln('  INSS.....: ', f[i].inss:2:2 );
                        writeln('  IRPF.....: ', f[i].irpf:2:2 );

                        s := f[i].sb - (f[i].inss + f[i].irpf);
                        writeln('  S.Liquido: ', s:2:2);
                        t := t + s;
                        writeln('');
                end;
                writeln('________________________________________');
                writeln('Total da Folha de Pagamento: ', t:2:2);
                readkey;

        end;

begin

        repeat
                clrscr;
                writeln('1 - Coletar Dados       ');
                writeln('2 - Relatorio Geral     ');
                writeln('3 - Encerrar o Programa ');
                op := readkey;

                case op of
                        '1': coletardados;
                        '2': relatorio;
                        '3': writeln('... Programa encerrado!');
                end;

        until op = '3';

end.
